Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Emit management canister idl during build when imported by Motoko canister #3329

Merged
merged 22 commits into from
Oct 1, 2023

Conversation

kentosugama
Copy link
Contributor

@kentosugama kentosugama commented Aug 25, 2023

Description

When Motoko canisters import the management canister

import management "ic:aaaaa-aa";

it would be ideal if the interface is automatically provided by dfx.

The execution team is planning on adding the idl to the replica, but until then it can be hard coded in dfx and swapped out later on.

How Has This Been Tested?

@test "build supports auto-generated idl for management canister imports in motoko" {
    install_asset motoko_management
    dfx_start
    dfx canister create --all
    assert_command dfx build
    dfx deploy
    assert_command dfx canister call e2e_project_backend rand
}
import Management "ic:aaaaa-aa";

actor {
  public func rand() : async Blob {
    await Management.raw_rand();
  };
};

And the recursive version of the test.

import Rand "dependency";

actor {
  public func rand() : async Blob {
    await Rand.rand();
  };
};

dependency.mo

import Management "ic:aaaaa-aa";

module Rand {
  public func rand() : async Blob {
    await Management.raw_rand();
  };
};

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.
  • Different subnets may have different management canisters

@chenyan-dfinity
Copy link
Contributor

The execution team is planning on adding the idl to the replica

Not going to happen. The difficulty is that we don't have a way to route aaaaa-aa, so it's not easy to get this endpoint.

@kentosugama
Copy link
Contributor Author

I spoke with @dsarlis this morning in the dx working group and he mentioned he was looking into building the feature

@chenyan-dfinity
Copy link
Contributor

That would be great!

@kentosugama kentosugama self-assigned this Aug 28, 2023
@kentosugama kentosugama marked this pull request as ready for review August 30, 2023 18:38
@kentosugama kentosugama requested review from chenyan-dfinity and a team as code owners August 30, 2023 18:38
@kentosugama
Copy link
Contributor Author

@ericswanson-dfinity Hi Eric. Not quite sure where the appropriate place for documenting this feature would be. I'm considering dfx build --help.

@ericswanson-dfinity
Copy link
Member

@ericswanson-dfinity Hi Eric. Not quite sure where the appropriate place for documenting this feature would be. I'm considering dfx build --help.

How about here? https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-build.md

src/dfx/src/lib/builders/motoko.rs Outdated Show resolved Hide resolved
src/dfx/src/util/assets.rs Show resolved Hide resolved
src/dfx/src/lib/builders/motoko.rs Outdated Show resolved Hide resolved
src/dfx/src/lib/builders/motoko.rs Outdated Show resolved Hide resolved
src/dfx/src/lib/builders/motoko.rs Show resolved Hide resolved
@kentosugama kentosugama merged commit a7be23c into master Oct 1, 2023
@kentosugama kentosugama deleted the LANG-294-management-did branch October 1, 2023 11:13
@mergify mergify bot removed the automerge-squash label Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants